﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_DAL;
using Zor_Modes;
using Zor_Tools;

namespace Zor_Bll
{
    public class Zor_CertificateStart_Bll<T> where T : class
    {

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageList(dynamic Model, int index, out int TotalCount, string where)
        {
            var sqlSurch = string.Empty;
            if (Model.Certificate_CreateTime != null)
            {
                int st = TimeHelper.ToTimeStamp(DateTime.Parse(Model.Certificate_CreateTime.ToString()));
                sqlSurch += "Certificate_CreateTime = " + st + " and ";
            }
            if (Model.Dt_Name != null)
            {
                sqlSurch += " Dt_Name like '%" + Model.Dt_Name + "%' and ";
            }
            if (Model.Certificate_StateName != null && Model.Certificate_StateName != "全部")
            {
                sqlSurch += " Certificate_StateName = '" + Model.Certificate_StateName + "' and ";
            }
            sqlSurch += "   Certificate_CollarMan = "+ RequestSession.GetSessionUser().DT_Id +" ";
            return PagerHelp<T>.GetPagerList(index, "V_Zor_Certificate", "Certificate_CreateTime desc", out TotalCount, sqlSurch);
        }

        /// <summary>
        /// 完税证作废
        /// </summary>
        /// <param name="id">选中完税证作废id</param>
        /// /// <param name="AcceptanceId">选中受理单id</param>
        /// /// <param name="PtId">选中缴税管理id</param>
        /// <returns></returns>
        public static BaseAnswer CertificateStart(int id, int StartTaxNum, int EndTaxNum)
        {
            BaseAnswer bar = Zor_Certificate_DAL<T>.CertificateStart(id, StartTaxNum, EndTaxNum);
            if (bar.AnswerType != BaseAnswer.Answers.Error)
                bar.AnswerMeg = bar.AnswerType == BaseAnswer.Answers.Succee ? "完税证启用成功！" : "完税证启用失败，请检查是否已启用！";
            return bar;
        }
    }
}
